package com.uidt.project.ptsj.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.uidt.framework.aspectj.lang.annotation.Log;
import com.uidt.framework.aspectj.lang.enums.BusinessType;
import com.uidt.project.ptsj.domain.PtsjXfzc;
import com.uidt.project.ptsj.service.IPtsjXfzcService;
import com.uidt.framework.web.controller.BaseController;
import com.uidt.framework.web.domain.AjaxResult;
import com.uidt.common.utils.poi.ExcelUtil;
import com.uidt.framework.web.page.TableDataInfo;

/**
 * 消防自查
Controller
 * 
 * @author uidt
 * @date 2024-08-27
 */
@RestController
@RequestMapping("/ptsj/xfzc")
public class PtsjXfzcController extends BaseController
{
    @Autowired
    private IPtsjXfzcService ptsjXfzcService;

    /**
     * 查询消防自查列表
     */
//    @PreAuthorize("@ss.hasPermi('ptsj:xfzc:list')")
    @GetMapping("/list")
    public TableDataInfo list(PtsjXfzc ptsjXfzc)
    {
        startPage();
        List<PtsjXfzc> list = ptsjXfzcService.selectPtsjXfzcList(ptsjXfzc);
        return getDataTable(list);
    }

    /**
     * 导出消防自查列表
     */
    @PreAuthorize("@ss.hasPermi('ptsj:xfzc:export')")
    @Log(title = "消防自查", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PtsjXfzc ptsjXfzc)
    {
        List<PtsjXfzc> list = ptsjXfzcService.selectPtsjXfzcList(ptsjXfzc);
        ExcelUtil<PtsjXfzc> util = new ExcelUtil<PtsjXfzc>(PtsjXfzc.class);
        util.exportExcel(response, list, "消防自查数据");
    }

    /**
     * 获取消防自查详细信息
     */
//    @PreAuthorize("@ss.hasPermi('ptsj:xfzc:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ptsjXfzcService.selectPtsjXfzcById(id));
    }

    /**
     * 新增消防自查
     */
//    @PreAuthorize("@ss.hasPermi('ptsj:xfzc:add')")
    @Log(title = "消防自查", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PtsjXfzc ptsjXfzc)
    {
        return toAjax(ptsjXfzcService.insertPtsjXfzc(ptsjXfzc));
    }

    /**
     * 修改消防自查
     */
    @PreAuthorize("@ss.hasPermi('ptsj:xfzc:edit')")
    @Log(title = "消防自查", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PtsjXfzc ptsjXfzc)
    {
        return toAjax(ptsjXfzcService.updatePtsjXfzc(ptsjXfzc));
    }

    /**
     * 删除消防自查

     */
    @PreAuthorize("@ss.hasPermi('ptsj:xfzc:remove')")
    @Log(title = "消防自查", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ptsjXfzcService.deletePtsjXfzcByIds(ids));
    }
}
